using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;

namespace PongGame
{
    /// <summary>
    /// This is the main type for your game
    /// </summary>
    public class Game1 : Microsoft.Xna.Framework.Game
    {

        SpriteManager spriteMgr;
        GraphicsDeviceManager graphics;
        SpriteBatch spriteBatch;
        static public int ScreenWidth, ScreenHeight;
        static public float DisplacementPerFrame;

        public Game1()
        {
            graphics = new GraphicsDeviceManager(this);
            Content.RootDirectory = "Content";

        }
        
        protected override void Initialize()
        {
            ScreenWidth = graphics.GraphicsDevice.Viewport.Width;
            ScreenHeight = graphics.GraphicsDevice.Viewport.Height;
            spriteMgr = new SpriteManager(this);
            Components.Add(spriteMgr);

            base.Initialize();
        }

        protected override void LoadContent()
        {
            
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);
        }

        protected override void UnloadContent()
        {
            // TODO: Unload any non ContentManager content here
            base.UnloadContent();
        }
 
        protected override void Update(GameTime gameTime)
        {
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
                this.Exit();

            // Move half way across the screen each second
            DisplacementPerFrame = 0.5f * (float)gameTime.ElapsedGameTime.TotalMilliseconds / 1000.0f;

            
            base.Update(gameTime);
        }

        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.CornflowerBlue);

            base.Draw(gameTime);
        }

        public static void StartGame()
        {
            using (Game1 game = new Game1())
            {
                game.Run();
            }
        }

    }

}
